use ggez::{glam::Vec2, Context};

pub struct Physics {
    pub location: Vec2,
    pub velocity: Vec2,
    pub topspeed: f32,
    pub acceleration: Vec2,

    pub a_location: f32,
    pub a_velocity: f32,
    pub a_topspeed: f32,
    pub a_acceleration: f32,

    pub size: f32,
    pub mass: f32,
}

impl Physics {
    pub fn check_edges(&mut self, ctx: &mut Context) -> () {
        if self.location.x > (ctx.gfx.window().inner_size().width as f32)-self.size {
            self.location.x = (ctx.gfx.window().inner_size().width as f32)-self.size;
            self.velocity.x = -self.velocity.x;
            self.a_velocity = self.velocity.y/10.0;
        }
        else if self.location.x < 0.0+self.size {
            self.location.x = 0.0+self.size;
            self.velocity.x = -self.velocity.x;
            self.a_velocity = self.velocity.y/10.0;
        }
    
        if self.location.y > (ctx.gfx.window().inner_size().height as f32)-self.size {
            self.location.y = (ctx.gfx.window().inner_size().height as f32)-self.size;
            self.velocity.y = -self.velocity.y;
            self.a_velocity = self.velocity.x/10.0;
        }
        else if self.location.y < 0.0+self.size {
            self.location.y = 0.0+self.size;
            self.velocity.y = -self.velocity.y;
            self.a_velocity = self.velocity.x/10.0;
        }
    }
}